/**
 * 组织架构的接口
 */
import request from "@/utils/request";

/**
 * 获取组织架构数据
 */
const getDepartments = () => request({
  url: '/company/department',
  method: 'GET'
})

/**
 * 根据ID删除部门
 * 接口是根据restful的规则设计的   
 * 同样的地址 不同的方法 执行不同的业务
 * 删除 delete  新增 post  修改put 获取 get
 */
const delDepartments = id => request({
  url: `/company/department/${id}`,
  method: 'DELETE'
})

/**
 * 新增部门
 */
const addDepartments = data => request({
  url: '/company/department',
  method: 'POST',
  data
})

/**
 * 根据ID查询部门详情
 */
const getDepartDetail = id => request({
  url: `/company/department/${id}`,
})

/**
 * 根据ID修改部门详情
 */
const updateDepartments = data => request({
  url: `/company/department/${data.id}`,
  method: 'PUT',
  data
})

export {
  getDepartments,
  delDepartments,
  addDepartments,
  getDepartDetail,
  updateDepartments
}
